Display Recent Posts and custom excerpts in your WordPress Theme Template
Today we are displaying our latest blog post in a WordPress template as only links or with a summary or excerpt.
The length of the excerpt can be defined to fit the size of the allocated area or <div></div> in your template. This is not a widget but coded to your main template page.
<?php query_posts('showposts=5'); ?> <ul> <?php while (have_posts()) : the_post(); ?> <li></li> <?php endwhile;?> </ul>
To add a summary or excerpt to the code above use the following code :
<?php query_posts('showposts=5'); ?> <ul> <?php while (have_posts()) : the_post(); ?> <li></li> <?php the_excerpt() ?> <?php endwhile;?> </ul>
The default length of the except is 50 characters. We will be changing the length of the expert to 30 by adding the code below to the theme’s functions.php, add_filter('excerpt_length', 'my_excerpt_length'); function my_excerpt_length($length) { return 30; }
To add imaegs to your excerpt use the Thumbnail for Excerpts WordPress Plugin.Download the Thumbnail for Excerpts WordPress Plugin.
// Changing excerpt more function new_excerpt_more($more) { global $post; return '… ' . 'Read More »' . ''; } add_filter('excerpt_more', 'new_excerpt_more');
Source : WordPress. The code here is lenghty but use it as reference
PhoenixCOZA’s Blog Posted via email from PhoenixCOZA’s Blog
Tags: WordPress
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.